﻿using System;
using System.Linq;
using System.Text;

namespace _22.ReplaceAllSeriesOfIdenticalLettersWithSingleOne
{
    class ReplaceAllSeriesOfIdenticalLettersWithSingleOne
    {
        static void Main(string[] args)
        {
            string text = "aaaaabbbbbcdddeeeedssaa";
            Console.WriteLine(text);
            StringBuilder singleLetters = new StringBuilder();
            for (int i = 0; i < text.Length - 1; i++)
            {
                if (text[i] != text[i + 1])
                {
                    singleLetters.Append(text[i]);
                }
            }
            singleLetters.Append(text[text.Length - 1]);
            string newText = singleLetters.ToString();
            Console.WriteLine(newText);
        }
    }
}
